Purpose
The arrayIncludes task is used to determine if an array includes a given element and then returns a "true" or "false" result, as appropriate. If used in conjunction with an index task, then you can specify where in the index the search should begin.
Potential Use Case
Suppose you have a list of emails and are looking to see if a certain address is in that list. You would specify the email address you want to find and if the email is present, then your result would come back as "true". If the email is not found in the list, then your result would come back as "false".
Properties
| Incoming | Type | Description |
|---|---|---|
arr |
Array | Required. The array to search. |
searchElement |
Any | Required. The element to search for. |
fromIndex |
Number | Optional. The position in the array to begin searching for a searchElement. Default is 0 (zero). |
| Outgoing | Type | Description |
|---|---|---|
result |
Boolean | True if the searchElement is found within the array; false otherwise. |
Example
In this IAP example:
The array is statically set and the reference variable is
["1","2","3"].The
searchElementto find is the number2.The
fromIndexvariable will default to 0.The
resultwill beTruebecause the number2is listed in the array.